package com.jh.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jh.mapper.EmpMapper;
import com.jh.pojo.Emp;
import com.jh.pojo.EmpQueryParam;
import com.jh.pojo.ResultPage;
import com.jh.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImpl implements EmpService {
    @Autowired
    private EmpMapper empMapper;

    @Override
    public ResultPage<Emp> listPage(EmpQueryParam empQueryParam) {
        PageHelper.startPage(empQueryParam.getPage(), empQueryParam.getPageSize());

        List<Emp> list = empMapper.listPage(empQueryParam);
        Page<Emp> p = (Page<Emp>) list;

        return new ResultPage<Emp>(p.getTotal(), p.getResult());
    }
}
